import 'package:flutter/material.dart';
import 'package:flutter_app/openeye/utils/toast_utils.dart';
import 'package:flutter_app/stateLearn/click_txt.dart';
import 'package:flutter_app/utils/download_pic_util.dart';

///author: create by SunJH
///时间: 2022/1/5 0005
///邮箱: 965989158@qq.com
///描述: 保存图片到本地测试
///

class SavePicTest extends StatelessWidget {
  const SavePicTest({Key? key}) : super(key: key);
  static const picUrl = "https://upload-images.jianshu.io/upload_images/795923-c5bcd041afcdfc23.png";
  static const downloadUrl = "https://frontend-store.oss-cn-chengdu.aliyuncs.com/cloud-school/home/elegant/nature/nature13.png";

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Column(
          children: [
            Image.network(downloadUrl,fit: BoxFit.cover,height: 500,width: 500,),
            ClickTxt(info: "下载图片", onPressed: (){
              DownloadPicUtil.saveImage(downloadUrl, (bool result) {
                ToastUtils.showTip(result?"保存成功":"保存失败");
              });
            })
          ],
        ),
      ),
    );
  }
}
